#include "CTrainer.h"
#include <string.h>
#include <iostream>
#include <stdlib.h>
#include <time.h>
#pragma warning(disable : 4996)

using namespace std;

CTrainer::CTrainer(const CTrainer &other) : Program(other.Program)
{
	TrainerName = new char[strlen(other.getTrainerName())+1];
	strcpy(TrainerName,other.getTrainerName());
}

CTrainer::CTrainer(const char * TName) : Program(getCurrentDate())
{
	TrainerName = NULL;
	setTrainerName(TName);
}

CTrainer::~CTrainer(void)
{
delete []TrainerName;
}
const char * CTrainer::getTrainerName() const 
{
	return TrainerName; 
}
void CTrainer::setTrainerName(const char *TName)
{
	
	int len = (int)strlen(TName);
	if (len==0)
		return;

	if (TrainerName!=NULL)
		delete []TrainerName;
	
	TrainerName = new char [len+1];

	strcpy(TrainerName,TName);

}

CProgram & CTrainer::getProgram()
{
	return Program;
}
CDate CTrainer::getCurrentDate()
{
time_t t = time(0);
tm lt;
localtime_s(&lt,&t);

return CDate(lt.tm_mday,lt.tm_mon+1,lt.tm_year+1900);

}
